<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>爆款公众号文章</title>
    <script src="../js/html2canvas.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: "PingFang SC", "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
            line-height: 1.7;
            color: #333;
            background: #fff;
            padding: 15px;
            max-width: 560px;
            margin: 0 auto;
            position: relative;
            transition: all 0.3s ease;
            font-size: 16px;
        }
        
        .article-container {
            background-color: white;
            border-radius: 8px;
            overflow: hidden;
            padding: 25px 20px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
        }
        
        .title {
            font-size: 22px;
            font-weight: bold;
            color: #000;
            margin-bottom: 20px;
            line-height: 1.4;
            text-align: left;
        }
        
        .content {
            font-size: inherit;
        }
        
        .content p {
            margin-bottom: 20px;
            text-align: justify;
            color: #333;
        }
        
        .content h2 {
            font-size: 18px;
            margin: 25px 0 15px;
            color: #000;
            padding-left: 10px;
            border-left: 4px solid #ff3a5c;
            font-weight: bold;
        }
        
        .highlight {
            background-color: #fff9fa;
            padding: 20px;
            border-radius: 8px;
            margin: 20px 0;
            border: 1px solid #ffe6e9;
            position: relative;
        }
        
        .highlight:before {
            content: "💡";
            position: absolute;
            top: -10px;
            left: 15px;
            background: white;
            padding: 0 5px;
            font-size: 16px;
        }
        
        .numbered-list {
            counter-reset: item;
            margin-left: 0;
            margin-bottom: 25px;
        }
        
        .numbered-list li {
            counter-increment: item;
            margin-bottom: 15px;
            list-style-type: none;
            position: relative;
            padding-left: 30px;
        }
        
        .numbered-list li:before {
            content: counter(item);
            background-color: #ff3a5c;
            color: white;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            position: absolute;
            left: 0;
            top: 2px;
            font-weight: bold;
        }
        
        .quote {
            border-left: 4px solid #ff3a5c;
            padding-left: 15px;
            margin: 20px 0;
            font-style: italic;
            color: #666;
            background: #f9f9f9;
            padding: 15px;
            border-radius: 0 8px 8px 0;
        }
        
        .divider {
            height: 1px;
            background: linear-gradient(90deg, transparent, #ddd, transparent);
            margin: 30px 0;
        }
        
        /* 右侧工具栏样式 */
        .toolbar {
            position: fixed;
            right: 15px;
            top: 50%;
            transform: translateY(-50%);
            display: flex;
            flex-direction: column;
            gap: 8px;
            z-index: 1000;
        }
        
        .tool-btn {
            width: 44px;
            height: 44px;
            border-radius: 50%;
            background-color: #ff3a5c;
            color: white;
            border: none;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            box-shadow: 0 4px 12px rgba(255, 59, 92, 0.3);
            transition: all 0.3s ease;
            font-size: 16px;
            font-weight: bold;
        }
        
        .tool-btn:hover {
            background-color: #e62e4d;
            transform: translateY(-2px);
        }
        
        /* 导出图片预览样式 */
        .image-preview {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.85);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 2000;
        }
        
        .preview-content {
            max-width: 90%;
            max-height: 90%;
            background-color: white;
            border-radius: 8px;
            padding: 20px;
            position: relative;
        }
        
        .preview-image {
            max-width: 100%;
            max-height: 80vh;
            display: block;
            margin: 0 auto;
        }
        
        .close-preview {
            position: absolute;
            top: 10px;
            right: 15px;
            background: none;
            border: none;
            font-size: 24px;
            cursor: pointer;
            color: #666;
        }
        
        .download-btn {
            display: block;
            margin: 15px auto 0;
            padding: 10px 20px;
            background-color: #ff3a5c;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        
        @media (max-width: 480px) {
            body {
                padding: 10px;
            }
            
            .article-container {
                padding: 20px 15px;
            }
            
            .toolbar {
                right: 10px;
            }
            
            .tool-btn {
                width: 40px;
                height: 40px;
                font-size: 14px;
            }
        }
    </style>
</head>
<body>
    <div class="toolbar">
        <button class="tool-btn" id="increaseFont" title="放大文字">A+</button>
        <button class="tool-btn" id="decreaseFont" title="缩小文字">A-</button>
        <button class="tool-btn" id="exportImage" title="导出长图">📷</button>
    </div>
    
    <div class="article-container" id="articleContent" contenteditable="true">
        <h1 class="title">月薪3千和3万的新媒体小编，差别就在这5个标题技巧！</h1>
        
        <div class="content">
            <p>为什么同样内容，别人的文章阅读量10万+，你的却只有几百？</p>
            
            <p>从事新媒体5年，我带过上百个小编，发现薪资差距巨大的核心原因，往往不是文笔，而是<strong>标题创作能力</strong>。</p>
            
            <div class="highlight">
                <p>好的标题能在3秒内抓住读者眼球，提升3-5倍打开率。今天分享5个经过验证的标题技巧，让你从小白秒变标题高手！</p>
            </div>
            
            <h2>一、数字+结果型标题</h2>
            <p>这是最简单有效的标题模式，数字给人具体感，结果给人期待感。</p>
            
            <div class="quote">
                "3个技巧，让我的公众号打开率从5%提升到20%"
            </div>
            
            <p>这种标题的威力在于：</p>
            
            <div class="numbered-list">
                <li>数字让内容显得具体可信</li>
                <li>结果激发读者的获取欲望</li>
                <li>适合教程、经验分享类内容</li>
            </div>
            
            <h2>二、疑问+解决方案型</h2>
            <p>直接戳中读者痛点，然后给出解决方案。</p>
            
            <div class="quote">
                "为什么你写的文章没人看？可能是这3个原因"
            </div>
            
            <p>这种标题的优势：</p>
            
            <div class="numbered-list">
                <li>精准定位目标读者</li>
                <li>激发好奇心</li>
                <li>暗示文章价值</li>
            </div>
            
            <div class="divider"></div>
            
            <h2>三、对比型标题</h2>
            <p>通过对比制造冲突，吸引读者点击。</p>
            
            <div class="quote">
                "月薪3千小编和月薪3万总监，差的不只是工作经验"
            </div>
            
            <p>对比型标题的要点：</p>
            
            <div class="numbered-list">
                <li>对比要足够鲜明</li>
                <li>突出差异点</li>
                <li>暗示提升路径</li>
            </div>
            
            <h2>四、揭秘型标题</h2>
            <p>满足人们对"内幕"、"秘密"的好奇心。</p>
            
            <div class="quote">
                "爆款文章背后的秘密：平台不会告诉你的3个流量密码"
            </div>
            
            <p>这种标题的关键：</p>
            
            <div class="numbered-list">
                <li>暗示独家信息</li>
                <li>制造稀缺感</li>
                <li>满足求知欲</li>
            </div>
            
            <h2>五、命令型标题</h2>
            <p>直接告诉读者应该做什么，简洁有力。</p>
            
            <div class="quote">
                "立即停止这5个标题错误！第3个90%的人都在犯"
            </div>
            
            <p>命令型标题的特点：</p>
            
            <div class="numbered-list">
                <li>语气强烈，印象深刻</li>
                <li>指出常见错误</li>
                <li>激发改正欲望</li>
            </div>
            
            <div class="highlight">
                <p><strong>总结：</strong>好的标题不是凭空想象，而是有规律可循的。掌握这5个技巧，结合你的内容特点，相信你的文章打开率会有明显提升！</p>
            </div>
            
            <p>实践是检验真理的唯一标准，现在就选一个技巧，为你下一篇文章创作标题吧！</p>
        </div>
    </div>
    
    <div class="image-preview" id="imagePreview">
        <div class="preview-content">
            <button class="close-preview" id="closePreview">×</button>
            <img class="preview-image" id="previewImage" src="" alt="文章长图预览">
            <button class="download-btn" id="downloadImage">下载文章图片</button>
        </div>
    </div>

    <script>
        // 字体大小控制
        let currentFontSize = 16;
        
        document.getElementById('increaseFont').addEventListener('click', function() {
            if (currentFontSize < 24) {
                currentFontSize += 2;
                updateFontSize();
            }
        });
        
        document.getElementById('decreaseFont').addEventListener('click', function() {
            if (currentFontSize > 12) {
                currentFontSize -= 2;
                updateFontSize();
            }
        });
        
        function updateFontSize() {
            // 设置body字体大小，所有子元素会继承
            document.body.style.fontSize = currentFontSize + 'px';
            
            // 特殊处理一些需要独立调整的元素
            const title = document.querySelector('.title');
            const baseTitleSize = 22;
            title.style.fontSize = (baseTitleSize * currentFontSize / 16) + 'px';
            
            const subTitles = document.querySelectorAll('h2');
            const baseSubTitleSize = 18;
            subTitles.forEach(subTitle => {
                subTitle.style.fontSize = (baseSubTitleSize * currentFontSize / 16) + 'px';
            });
            
            // 处理编号列表中的数字大小
            const listItems = document.querySelectorAll('.numbered-list li:before');
            const baseNumberSize = 12;
            document.querySelectorAll('.numbered-list li').forEach(item => {
                const beforeStyle = getComputedStyle(item, '::before');
                item.style.setProperty('--number-size', (baseNumberSize * currentFontSize / 16) + 'px');
            });
        }
        
        // 导出长图功能
        document.getElementById('exportImage').addEventListener('click', function() {
            const articleContent = document.getElementById('articleContent');
            
            const originalText = this.innerHTML;
            this.innerHTML = '生成中...';
            this.disabled = true;
            
            html2canvas(articleContent, {
                scale: 2,
                useCORS: true,
                allowTaint: true,
                backgroundColor: '#ffffff'
            }).then(canvas => {
                this.innerHTML = originalText;
                this.disabled = false;
                
                const preview = document.getElementById('imagePreview');
                const previewImage = document.getElementById('previewImage');
                
                previewImage.src = canvas.toDataURL('image/png');
                preview.style.display = 'flex';
            }).catch(error => {
                console.error('生成图片失败:', error);
                alert('生成图片失败，请重试');
                this.innerHTML = originalText;
                this.disabled = false;
            });
        });
        
        // 关闭预览
        document.getElementById('closePreview').addEventListener('click', function() {
            document.getElementById('imagePreview').style.display = 'none';
        });
        
        // 下载图片
        document.getElementById('downloadImage').addEventListener('click', function() {
            const previewImage = document.getElementById('previewImage');
            const link = document.createElement('a');
            link.download = '爆款标题技巧文章.png';
            link.href = previewImage.src;
            link.click();
        });
    </script>
</body>
</html>